import React, {useState, useEffect} from 'react';
import Orders from '../orders/Orders';
import { useSelector, useDispatch } from 'react-redux';
import {TOGGLE_COMPLETE} from '../../store/action/Type';

const Home = (props: any) => {
    const [count, setCount] = useState(0);
    // const [aa, setAa] = useState(0);
    let state = useSelector((state:any) => state.reducer.list);
    console.log(state)
    let dispatch = useDispatch();

    useEffect(() => {
        // console.log(`You clicked ${count} times`);
    },[count]);

    function reder() {
        dispatch({
            type: TOGGLE_COMPLETE, count: 1
        });
    }

    return (
        <div>x
            <Orders {...props} />
            <p>大家都卡尽快尽快发了{state}</p>
            <button onClick={() => reder()}>Click me  aaaaaaa</button>
            <p>You clicked {count} times</p>
            <button onClick={() => setCount(count + 1)}>Click me</button>
        </div>
    );
}

export default Home